#pragma once

#include "XWaterOpenGL_global.h"
#include<extensionsystem/iplugin.h>
#include<XWaterUIPlugin.h>
#include<QWidget>
#include<QOpenGLWidget>
#include"XWaterOpenGLWidget.h"
#include<QButtonGroup>
#include<osgManipulator/TabPlaneTrackballDragger>
#include<osgGA/KeySwitchMatrixManipulator>
#include<pickTest.h>
class XWATEROPENGL_LIB_EXPORT XWaterOpenGL :public XWaterUIPlugin
{
	Q_OBJECT
		Q_INTERFACES(XWaterUIPlugin)
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
		Q_PLUGIN_METADATA(IID XWaterPlugin_iid FILE "XWaterOpenGL.json")
#endif
public:
    XWaterOpenGL();
	~XWaterOpenGL();
	virtual bool initialize(const QStringList& arguments, QString* errorString)Q_DECL_OVERRIDE;
	virtual void extensionsInitialized();
	virtual QWidget* getDisplayWidget() Q_DECL_OVERRIDE;
	virtual void handlePluginMetaData(XWaterMetaData pluginMetaData) Q_DECL_OVERRIDE;
	osg::Group* createScene();
	osg::Group* createPagedLODScene();
	void initKeySwitchMatrixManipulator();
	void convert2PagedLOD(std::string srcFilePath, std::string destFilePath, bool makeAllChildrenPaged);
public slots:
	void pluginSelected(QString name);
signals:
	void reportPluginMetaData(XWaterMetaData pluginMetaData);
	void pluginLoaded(QString name, QString iconUrl);
protected:
	bool eventFilter(QObject* obj, QEvent* event) override;
private:
	//QOpenGLWidget* openglWidget = new XWaterOpenGLWidget();
	//QOpenGLWidget* openglWidget = new osgQOpenGLWidget();
	QWidget* mainWgt = new QWidget();
	QButtonGroup* btnGrp = new QButtonGroup(this);
	osgQOpenGLWidget* pOsgQOpenGLWidget = new XWaterOsg();
	osg::ref_ptr <osgGA::KeySwitchMatrixManipulator> keySwitchManipulator = new osgGA::KeySwitchMatrixManipulator();
	osg::ref_ptr <DraggerHandler> dragHandler = new DraggerHandler();
};
Q_DECLARE_INTERFACE(XWaterOpenGL, "plugin.interface.XWaterOpenGL")
